



class Difference:
    def __init__(self,nums) -> None:
        assert len(nums) > 0
        self.diff = [0] * len(nums)

        self.diff[0] = nums[0]
        # 根据初始数组构造差分数组
        for i in range(1,len(nums)):
            self.diff[i] = nums[i] - nums[i - 1]

        #给闭区间[i,j]增加val
    def increment(self,i,j,val):
        self.diff[i] += val
        if j + 1 < len(self.diff):
            self.diff[j+1] -= val

        #返回结果数组
    def result(self):
        res = [0] * len(self.diff)
        res[0] = self.diff[0]
        for i in range(len(self.diff)):
            res[i] = res[i-1] + self.diff[i]
        return res

